package com.cskaoyan.shopping.controller.feign;

import com.cskaoyan.mall.dto.ItemToOrderDTO;
import com.cskaoyan.shopping.converter.ItemToOrderConverterMapper;
import com.cskaoyan.shopping.dal.entitys.Item;
import com.cskaoyan.shopping.dal.persistence.ItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author silic xia
 * @since 2022/12/03 18:30
 */

@RestController
public class OrderFeignController {

    @Autowired
    ItemMapper itemMapper;
    @Autowired
    ItemToOrderConverterMapper itemToOrderConverterMapper;

    @GetMapping("feign/order")

    public ItemToOrderDTO selectItemByPrimaryKey(Long productId){
        Item item = itemMapper.selectByPrimaryKey(productId);
        ItemToOrderDTO itemDto = itemToOrderConverterMapper.itemToItemDto(item);
        return itemDto;
    }

}

